package com.fz.song.feibao.web.controller.admin;


import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fz.song.feibao.framework.common.R;
import com.fz.song.feibao.web.entity.Admin;
import com.fz.song.feibao.web.service.IAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 宋发准
 * @since 2021-10-29
 */

@Api(tags = "用户控制器")
@RestController
@Slf4j
public class UserController {


    @Autowired
    private IAdminService adminService;

    @ApiOperation("获取所有用户信息")
    @GetMapping("users")
    @SaCheckLogin
    public R getUser() {

        String tokenName = StpUtil.getTokenName();
        String tokenValue = StpUtil.getTokenValue();

        log.info("tokenName:{}", tokenName);
        log.info("tokenValue:{}", tokenValue);

        LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Admin::getId, 1);
        wrapper.eq(Admin::getDel, 0);
        List<Admin> list = adminService.list(wrapper);
        return R.ok("查询用户集合成功", list);
    }

}
